<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="common/header.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<div id="page-wrapper">
		<div id="page-inner">
			<form class="form"
				action="${pageContext.request.contextPath }/provider/modifyPwd"
				method="post" id="submit" enctype="multipart/form-data"
				onsubmit="return check()">
				<div class="form-group">
					<label for="password">输入原密码：<span id="msg1"
						style="color:red;"></span></label> <input type="text" id="password"
						name="password" onblur="a2()" required="required"> <span
						id="error1"></span>
				</div>
				<!--/.form-group -->
				<div class="form-group">
					<label for="password2">新密码：</label> <input type="text"
						required="required" id="password2" name="password2" onblur="a4()">
					<span style="color:red" id="error2"></span>
				</div>
				<!--/.form-group -->
				<div class="form-group">
					<label for="password3">再次输入新密码：</label> <input type="text"
						required="required" id="password3" name="password3" onblur="a4()">
					<span style="color:red" id="error3"></span>
				</div>
				<!--/.form-group -->

				<br />
				<div class="col-md-2 col-md-push-2">
					<button type="submit" class="btn btn-danger" id="login-button">提交保存</button>
				</div>

				<div class="col-md-2 col-md-push-6">
					<input type="button" id="backbtn" value="返回上页"
						class='btn btn-success' />
				</div>

			</form>
		</div>
	</div>

	<!-- JS Scripts-->
    <!-- jQuery Js -->
    <%@include file="common/js.jsp"%>
    <script type="text/javascript">
    var flag = false ;
    
    function a2(){
	var pwd = $("#password").val();
	var i= pwd.length;
	
		if(i==6 || i==""){
			$("#error1").html("");
			$.ajax({
			url:"/Trip/provider/password",
			data:{oldpassword:pwd},
			dataType:"json",
			success:function(data){
			if(data == "false"){
				$("#error1").html("原密码错误！请重新输入！！！");
				$("#password").html();
			}else if(data == "true"){
				$("#error1").html("原密码输入正确！");
				flag = true ;
			}
			}
			});
			
		}else{
			$("#error1").html("密码长度必须为6位");
		}
		
}
	//判断新密码
	function a4(){
	var _pwd1 = $("#password2").val();
	var j = _pwd1.length;
	var _pwd2 = $("#password3").val();
	var k = _pwd2.length; 
	if(j==6 || j==""){
		 if(_pwd1==_pwd2){
		$("#error3").html("");
		flag = true ;
		}else{
		$("#error3").html("两次输入的新密码不一致，请重新输入");
		$("#password3").val("");
		} 
		
	}else{
	$("#error2").html("密码长度必须为6位,请重新输入");
	$("#password2").val("");
	$("#error2").html("");
	}
	
	}


function check(){
	if(flag=a2()){
		if(flag=a4()){
		return true;
		}else{
		return false;
		}
	}
	
}


</script>
</body>
</html>